package com.thundern.tdcrawler.selector;

import java.util.ArrayList;
import java.util.List;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;

public abstract class BaseElementSelector implements Selector, ElementSelector{

	public String select(String text) {
		if(text != null) {
			return  select(Jsoup.parse(text)) ;
		}
		return null;
	}
	
	public List<String> selectList(String text) {
		if(text != null) {
			return selectList(Jsoup.parse(text));
		}else {
			return new ArrayList<String>();
		}
	}
	
	public Element selectElement (String text) {
		if(text != null) {
			return selectElement(Jsoup.parse(text));
		}
		return null;
	}
	
	public List<Element> selectElements(String text) {
		if(text != null){
			return selectElements(Jsoup.parse(text));
		}else {
			return new ArrayList<Element>();
		}
	}
	
	public abstract Element selectElement(Element element);
	
	public abstract List<Element> selectElements(Element element);
	
	public abstract boolean hasAttribute();
}
